#!/usr/bin/env perl
use strict;
use warnings;
=pod
@描述：
	1.计算9大车型 dbhome searchterm newenerge的pv uv 跳出pv 跳出uv值
	2.这里使用perl就是看中perl在正则匹配上的方便
@作者：范洪星
@日期：2014年4月11日 星期五 上午
=cut

while(my $line = <>) {
	chomp($line);
	my @cols = split(/\t/,$line);
	
	my $suv = $cols[3];
	my $domain = $cols[4];
	my $url = $cols[5];
	my $refer = $cols[8];
	my $whole = $domain.$url;
	#--分成pvuv计算和go_pvuv计算--#
	#开始pvuv类计算
	if($domain eq "auto.sohu.com"){
		if($url eq "/newenerge/"){
			printf("newenerge_pvuv\t%s\t%s\n",1,$suv);
		}
	} elsif($domain eq "db.auto.sohu.com"){
		if($url =~ /\/(model-list-|index|$)/){
			printf("dbhome_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/searchterm.sip/){
			printf("searchterm_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/a00[\.|-]/){
			printf("a00_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/a0[\.|-]/){
			printf("a0_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/a[\.|-]/){
			printf("a_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/b[\.|-]/){
			printf("b_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/c[\.|-]/){
			printf("c_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/luxury[\.|-]/){
			printf("luxury_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/mpv[\.|-]/){
			printf("mpv_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/suv[\.|-]/){
			printf("suv_pvuv\t%s\t%s\n",1,$suv);
		} elsif($url =~ /\/sportscars[\.|-]/){
			printf("sportscars_pvuv\t%s\t%s\n",1,$suv);
		}
	}
	#开始计算go_pvuv
	if($refer =~ /auto.sohu.com\/newenerge/ && $whole !~ /auto.sohu.com\/newenerge/){
		printf("newenerge_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/searchterm.sip/ && $whole !~ /db.auto.sohu.com\/searchterm.sip/){
		printf("searchterm_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com(\/model-list-|\/index|$)/ && $whole !~ /db.auto.sohu.com\/(model-list-|index|$)/){
		#printf("%s\t%s\n",$refer,$whole);
		printf("dbhome_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/a00[\.|-]/ && $whole !~ /db.auto.sohu.com\/a00[\.|-]/){
		printf("a00_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/a0[\.|-]/ && $whole !~ /db.auto.sohu.com\/a0[\.|-]/){
		printf("a0_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/a[\.|-]/ && $whole !~ /db.auto.sohu.com\/a[\.|-]/){
		printf("a_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/b[\.|-]/ && $whole !~ /db.auto.sohu.com\/b[\.|-]/){
		printf("b_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/c[\.|-]/ && $whole !~ /db.auto.sohu.com\/c[\.|-]/){
		printf("c_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/luxury[\.|-]/ && $whole !~ /db.auto.sohu.com\/luxury[\.|-]/){
		printf("luxury_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/mpv[\.|-]/ && $whole !~ /db.auto.sohu.com\/mpv[\.|-]/){
		printf("mpv_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/suv[\.|-]/ && $whole !~ /db.auto.sohu.com\/suv[\.|-]/){
		printf("suv_go\t%s\t%s\n",1,$suv);
	} elsif($refer =~ /db.auto.sohu.com\/sportscars[\.|-]/ && $whole !~ /db.auto.sohu.com\/sportscars[\.|-]/){
		printf("sportscars_go\t%s\t%s\n",1,$suv);
	}
}
